######################################################################
# Time-stamp: <03/11/20 17:34:13 ostolop>
#
# Some legacy routines to deal with EPCLUST
#
# Initially written by Jaak Vilo
######################################################################
package EP::Legacy::EPCLUST;

use EP::Config;

sub define_clustering_choices
{

        %DISTANCES = (
                "eucl"          => "Euclidean distance" ,
                "euclsqr"       => "Euclidean distances squared" ,

                "ave"           => "Average distance",
                "avesqrrt"      => "Square root of Average distance",

                "signsum"       => "Number of attributes with opposite sign",

                "manh"          => "Manhattan distance" ,
                "manh_nonzero"  => "Manhattan distance for nonzero values",

                "corr"          => "Correlation measure based distance (uncentered)",
                "abscorr"       => "Absolute correlation measure based distance",


                "pearson"       => "Linear correlation based distance (Pearson, centered)",
                "abspearson"    => "Absolute value of linear correlation based distance (Pearson)",

                "chord"         => "Chord distance",
                "chordnorm"     => "Euclidean distance on normalized vectors of length 1 (chord distance)",

                "rank" => "Spearman's rank correlation based distance",

                "toprank_5" => "Spearman's rank correlation based distance for 5",
                "toprank_10" => "Spearman's rank correlation based distance for 10",
                "toprank_20" => "Spearman's rank correlation based distance for 20",
                "toprank_30" => "Spearman's rank correlation based distance for 30",
                "toprank_40" => "Spearman's rank correlation based distance for 40",
                "toprank_50" => "Spearman's rank correlation based distance for 50",
                "toprank_60" => "Spearman's rank correlation based distance for 60",
                "toprank_70" => "Spearman's rank correlation based distance for 70",
                "toprank_80" => "Spearman's rank correlation based distance for 80",
                # "test" => "Testing purposes" ,
        ) ;

        @DISTANCES = qw( corr eucl pearson group1  euclsqr ave avesqrrt manh group2 corr abscorr pearson
                  abspearson chord chordnorm group3 rank signsum manh_nonzero);

        %SEQDISTANCES = (
                "infcontent", "Distance based on contiguous matches" ,
                "matches", "Max. nr. of matches / length of shorter pattern",
                "peptides" , "Peptides_test" ,
                "peptides_transform", "Peptides, transform to vectors..." ,
        ) ;

        @SEQDISTANCES = qw( 
		infcontent
		group_s_1 infcontent matches 
		group_s_2 peptides peptides_transform 
	);

        push @DISTANCES , qw( toprank_5 toprank_10 toprank_20 toprank_30 toprank_40 toprank_50
                       toprank_60 toprank_70 toprank_80 ) if $EPdev &&
                       $MUHU ;

        %EPDISTANCES = %DISTANCES ;
        @EPDISTANCES = @DISTANCES ;


        %HCLUSTERINGS = (
                "min" => "Single linkage (minimum distance)",
                "max" => "Complete linkage (maximum distance)",
                "ave" => "Average linkage (average distance, UPGMA)",
                "WPGMA" => "Average linkage (weighted group average, WPGMA)",
                "none" => "No real clustering, just show the data",
        ) ;
        @HCLUSTERINGS = qw( ave max min WPGMA none );

        %PART_CLUSTERINGS = (
                "start_maxave" => "Initialize by most distant (average) genes",
                "start_maxmin" => "Initialize by most distant (minimum) genes",
                "start_random" => "Initialize by random genes",
                "start_discr"  => "Initialize by discretization",
                "select"  => "Initialize from list, select surrounding",
        ) ;
        @PART_CLUSTERINGS = qw( start_maxave start_maxmin start_random start_discr) ;


#        if( -f "$ABSOLUTE_FOLDER/.sequences" ) {
#                %DISTANCES = %SEQDISTANCES ;
#                @DISTANCES = @SEQDISTANCES ;
#        }

}

sub define_color_choices
{
    
    my $IMG_PREF = "$EP::Config::h->{HTML_HREF}/static/images/color_schemes" ; 
    
    ######################################################################
    # See standalone.generate_web_graphics.pl for how to make the thumbnails for these choices ...
    ######################################################################
    @GLOBAL_IMG_CHOICES = () ; 
    
    foreach $d ( 20 ) {
	push @GLOBAL_IMG_CHOICES , [ "$IMG_PREF/green_black_red.ari.$d.png" , "Green Black Red, $d harmonic" , 
				     { 'colors' => '#00ff00,#000000,#ff0000', 'NA_color' => '#888888', 'nr_slots' => $d , 'discr_type' => 'ari' } ] ; 
    }
    
    foreach $d ( 10 , 30 , 100 ) {
	push @GLOBAL_IMG_CHOICES , [ "$IMG_PREF/green_black_red.lin.$d.png" , "Green Black Red, $d linear" , 
				     { 'colors' => '#00ff00,#000000,#ff0000', 'NA_color' => '#0000ff', 'nr_slots' => $d , 'discr_type' => 'lin' } ] ; 
    }
    foreach $d ( 10 , 30 , 100 ) {
	push @GLOBAL_IMG_CHOICES , [ "$IMG_PREF/green_black_red.ari.$d.png" , "Green Black Red, $d harmonic" , 
				     { 'colors' => '#00ff00,#000000,#ff0000', 'NA_color' => '#0000ff', 'nr_slots' => $d , 'discr_type' => 'ari' } ] ; 
    }
    foreach $d ( 10 , 30 ) {
	push @GLOBAL_IMG_CHOICES , [ "$IMG_PREF/green_black_red.bin.$d.png" , "Green Black Red, $d exponential" , 
				     { 'colors' => '#00ff00,#000000,#ff0000', 'NA_color' => '#0000ff', 'nr_slots' => $d , 'discr_type' => 'bin' } ] ; 
    }
    
    foreach $d ( 10 , 30 , 100 ) {
	push @GLOBAL_IMG_CHOICES , [ "$IMG_PREF/blue_white_pink.lin.$d.png" , "Blue White Pink, $d linear" , 
				     { 'colors' => '#1e90ff,#ffffff,#ff69b4', 'NA_color' => '#aaaaaa', 'nr_slots' => $d , 'discr_type' => 'lin' } ] ; 
    }
    foreach $d ( 10 , 30 , 100 ) {
	push @GLOBAL_IMG_CHOICES , [ "$IMG_PREF/blue_white_pink.ari.$d.png" , "Blue White Pink, $d harmonic" , 
				     { 'colors' => '#1e90ff,#ffffff,#ff69b4', 'NA_color' => '#aaaaaa', 'nr_slots' => $d , 'discr_type' => 'ari' } ] ; 
    }
    foreach $d ( 10 ,  30 ) {
	push @GLOBAL_IMG_CHOICES , [ "$IMG_PREF/blue_white_pink.bin.$d.png" , "Blue White Pink, $d exponential" ,
				     { 'colors' => '#1e90ff,#ffffff,#ff69b4', 'NA_color' => '#aaaaaa', 'nr_slots' => $d , 'discr_type' => 'bin' } ] ; 
    }

}

1;
